﻿using System;
using UnityEngine;

namespace ParticlePlayground
{
	// Token: 0x020001AB RID: 427
	[Serializable]
	public class CollisionCache
	{
		// Token: 0x060009BC RID: 2492 RVA: 0x000496E0 File Offset: 0x000478E0
		public CollisionCache(int amount)
		{
			this.hasCollided = new bool[amount];
			this.collisionPosition = new Vector3[amount];
			this.collisionNormal = new Vector3[amount];
			this.collisionTransform = new Transform[amount];
			this.collisionGameObject = new GameObject[amount];
			this.collisionTransformPosition = new Vector3[amount];
			this.stickyPosition = new Vector3[amount];
		}

		// Token: 0x060009BD RID: 2493 RVA: 0x00049748 File Offset: 0x00047948
		public virtual void Set(int index, Vector3 position, Vector3 normal, Transform transform)
		{
			index %= this.hasCollided.Length;
			this.hasCollided[index] = true;
			this.collisionPosition[index] = position;
			this.collisionNormal[index] = normal;
			this.collisionTransform[index] = transform;
			this.collisionGameObject[index] = transform.gameObject;
		}

		// Token: 0x060009BE RID: 2494 RVA: 0x000497A8 File Offset: 0x000479A8
		public virtual void SetSticky(int index, Vector3 position, Vector3 normal, float offset, Transform transform)
		{
			index %= this.hasCollided.Length;
			this.hasCollided[index] = true;
			this.collisionPosition[index] = position;
			this.collisionNormal[index] = normal;
			this.collisionTransform[index] = transform;
			this.collisionGameObject[index] = transform.gameObject;
			this.collisionTransformPosition[index] = transform.InverseTransformPoint(position + this.collisionNormal[index] * offset);
		}

		// Token: 0x060009BF RID: 2495 RVA: 0x00049840 File Offset: 0x00047A40
		public virtual void UpdateStickyPosition(int index)
		{
			index %= this.stickyPosition.Length;
			if (this.collisionGameObject[index] != null && this.collisionGameObject[index].activeSelf && this.collisionGameObject[index].activeInHierarchy)
			{
				this.stickyPosition[index] = this.collisionTransform[index].TransformPoint(this.collisionTransformPosition[index]);
			}
			else
			{
				this.hasCollided[index] = false;
			}
		}

		// Token: 0x060009C0 RID: 2496 RVA: 0x000498D0 File Offset: 0x00047AD0
		public virtual void Reset(int index)
		{
			index %= this.hasCollided.Length;
			this.hasCollided[index] = false;
		}

		// Token: 0x060009C1 RID: 2497 RVA: 0x000498E8 File Offset: 0x00047AE8
		public virtual void ClearCollisions()
		{
			for (int i = 0; i < this.hasCollided.Length; i++)
			{
				this.hasCollided[i] = false;
			}
		}

		// Token: 0x060009C2 RID: 2498 RVA: 0x00049918 File Offset: 0x00047B18
		public virtual CollisionCache Clone()
		{
			return new CollisionCache(this.collisionPosition.Length)
			{
				hasCollided = (bool[])this.hasCollided.Clone(),
				collisionPosition = (Vector3[])this.collisionPosition.Clone(),
				collisionNormal = (Vector3[])this.collisionNormal.Clone(),
				collisionTransform = (Transform[])this.collisionTransform.Clone(),
				collisionTransformPosition = (Vector3[])this.collisionTransformPosition.Clone(),
				stickyPosition = (Vector3[])this.stickyPosition.Clone()
			};
		}

		// Token: 0x04000B8E RID: 2958
		[HideInInspector]
		public bool[] hasCollided;

		// Token: 0x04000B8F RID: 2959
		[HideInInspector]
		public Vector3[] collisionPosition;

		// Token: 0x04000B90 RID: 2960
		[HideInInspector]
		public Vector3[] collisionNormal;

		// Token: 0x04000B91 RID: 2961
		[HideInInspector]
		public Transform[] collisionTransform;

		// Token: 0x04000B92 RID: 2962
		[HideInInspector]
		public GameObject[] collisionGameObject;

		// Token: 0x04000B93 RID: 2963
		[HideInInspector]
		public Vector3[] collisionTransformPosition;

		// Token: 0x04000B94 RID: 2964
		[HideInInspector]
		public Vector3[] stickyPosition;
	}
}
